#ifndef TESTINGMAINWIDGET_H
#define TESTINGMAINWIDGET_H

#include <QWidget>
#include <QTableWidget>
#include <QtPrintSupport/QPrinter>
#include <QTextDocument>
#include "bottomlightbutton.h"
#include "rightlightbutton.h"
#include "serialportset.h"
#include <ActiveQt/QAxObject>
namespace Ui {
class testingMainWidget;
}
#ifndef TESTINF_
#define TESTINF_
struct TestInfo{
    QString num;
    QString open;
    QString close;
};

#endif
class testingMainWidget : public QWidget
{
    Q_OBJECT

public:
    explicit testingMainWidget(QWidget *parent = nullptr);
    ~testingMainWidget();
//    serialPortSet *sends;
private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();
    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

signals:
    void send2byte(QStringList);
    void transitHoldTime(int);
    void send2Cali(QString);
    void initFailed();
    void startSignal();
    void stopSignal();
private:
    Ui::testingMainWidget *ui;
    QTableWidget *tabWidget;
    bottomLightButton *botButton;
    rightLightButton  *rigButton;
    QStringList headerList;
    void initForm();
    void initData();
    void setTableWidget();
    bool checkDataFunc();

    void startAllAction();
    QByteArray handleCom2ByteReturn(QByteArray byte);
    QString tmpStr="";
    void handleOpenCloseData(QString, QString);
    QList<TestInfo> tableInfo;
    QString suveyor;
    QString shifts;
    bool isInit = true;
    void print2Epson();
public slots:
    void setSampleComboxChanged(int);
    void setTableHeader(QStringList);

    void handleSerialReturn();
    void setSuveyor(QString sr){
        suveyor = sr;
    }
    void setShitfs(QString sr){
        shifts = sr;
    }
    void setInitFailed(){
        isInit = false;
    }
private:
    int haveCheckNum = 0;//已经测试数据
    int needCheckNum = 0;
    int maxOpen = 0;
    int maxClose = 0;
    int minOpen = 99999;
    int minClose = 99999;
    qreal severalOpen = 0.0;
    qreal severalClose = 0.0;
    qreal testFlag;
    void calcuStandardDeviation();
    bool isStart = false;
    void setStartDisabled();
    void setStopAbled();
    QString dateNumber;
    void initSuveyorShitfs();
    //调用打印机
    QString htmlStr;    //打印数据
    QPrinter p;         //打印对象
    QTextDocument doc;  //文档对象
    bool ifPrint = false;
    void saveTabel2Excel();
};

#endif // TESTINGMAINWIDGET_H
